#!/usr/bin/env python
# -*- coding:utf-8 -*-
# file:do_fibonacci.py
# author:张仁
# datetime:2021/6/13 20:08
# software: PyCharm
"""
    斐波那契数列
"""


def fibonacci1(n):
    """求斐波那契数列

    采用递推的方法"""
    a, b = 0, 1
    for _ in range(n + 1):
        a, b = b, a + b
    return a


def fibonacci2(n):
    """求斐波那契数列

    采用递归的方法"""
    assert n >= 0, "n应该大于0"
    if n <= 1:
        return n
    return fibonacci2(n - 1) + fibonacci2(n - 2)
